<label for="chanxian"><g:message code="moc.ta.select.chanxian.label" />:</label> 
<g:select from="${line}" value="${params.line}" name="line" id="chanxian" onchange="return lineChanged(this.value)"/>

<script>
	function setUrlParam(url, param, v){
		var re = new RegExp("(\\\?|&)" + param + "=([^&]+)(&|$)", "i");
		var m = url.match(re);
		if (m){
			return (url.replace(re, function($0, $1, $2) { return ($0.replace($2, v)); } ));
		}else{
			if (url.indexOf('?') == -1)
				return (url + '?' + param + '=' + v);
			else
				return (url + '&' + param + '=' + v);
		}
	}
	function getUrlParam(url, param){
		var re = new RegExp("(\\\?|&)" + param + "=([^&]+)(&|$)", "i");
		var m = url.match(re);
		if (m)
			return m[2];
		else
			return '';
	}
	function lineChanged(value){
		//alert(encodeURI(value))
		setUrlParam(window.location.href, "offset", 0);
		setUrlParam(window.location.href, "max", 100);
		window.location.href = setUrlParam(window.location.href, "line", encodeURI(value));
	}
</script>
Total=${tbInstanceTotal}
<br/>
<g:set var="ta_id" scope="page" >${params['id']}</g:set>
<div class="paginateButtons">
    <g:paginate action="show" max="100" total="${tbInstanceTotal}" params="[id: ta_id, line : params.line]" />
</div>
<div class="list">
	<table>
	    <thead>
	        <tr>
	        	<th>View</th>
	            <g:sortableColumn property="tb001" title="${message(code: 'moc.tb.tb001.label', default: 'Tb001')}" action="show" params="[line : params.line]"/>
	            <g:sortableColumn property="tb010" title="${message(code: 'moc.tb.tb010.label', default: 'Tb010')}" action="show" params="[line : params.line]"/>
	            <g:sortableColumn property="tb002" title="${message(code: 'moc.tb.tb002.label', default: 'Tb002')}" action="show" params="[line : params.line]"/>
	            <g:sortableColumn property="tb008" title="${message(code: 'moc.tb.tb008.label', default: 'Tb008')}" action="show" params="[line : params.line]"/>
	            <g:sortableColumn property="tb003" title="${message(code: 'moc.tb.tb003.label', default: 'Tb003')}" action="show" params="[line : params.line]"/>
	            <g:sortableColumn property="tb011" title="${message(code: 'moc.tb.tb011.label', default: 'Tb011')}" action="show" params="[line : params.line]"/>
	            <g:sortableColumn property="tb012" title="${message(code: 'moc.tb.tb012.label', default: 'Tb012')}" action="show" params="[line : params.line]"/>
	            <g:sortableColumn property="tb004" title="${message(code: 'moc.tb.tb004.label', default: 'Tb004')}" action="show" params="[line : params.line]"/>
	            <g:sortableColumn property="tb005" title="${message(code: 'moc.tb.tb005.label', default: 'Tb005')}" action="show" params="[line : params.line]"/>
	            <g:sortableColumn property="tb006" title="${message(code: 'moc.tb.tb006.label', default: 'Tb006')}" action="show" params="[line : params.line]"/>
	            <th><g:message code="moc.tb.tb007.label"  default="Tb007"  />
	            <g:sortableColumn property="beginDate" title="${message(code: 'moc.tb.beginDate.label', default: 'Begin Date')}" action="show" params="[line : params.line]"/>
	            <g:sortableColumn property="endDate" title="${message(code: 'moc.tb.endDate.label', default: 'End Date')}" action="show" params="[line : params.line]"/>
	            <th><g:message code="moc.tb.tb009.label"  default="Tb009"  />
	        </tr>
	    </thead>
	    <tbody>
	    <g:each in="${tbInstanceList}" status="i" var="tbInstance">
	        <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
	        	<td><a href="${createLink(controller:'tb', action:'show', id : tbInstance.id)}" target="_blank" style="color:#0033CC;">VIEW</a></td>
	        	<td><a href="${createLink(controller:'tc', action:'create', params : [tb_id : tbInstance.id])}" target="_blank">${fieldValue(bean: tbInstance, field: "tb001")}</a></td>
	            <td><a href="${createLink(controller:'tc', action:'create', params : [tb_id : tbInstance.id])}" target="_blank">${fieldValue(bean: tbInstance, field: "tb010")}</a></td>
	        	<td><a href="${createLink(controller:'tc', action:'create', params : [tb_id : tbInstance.id])}" target="_blank">${fieldValue(bean: tbInstance, field: "tb002")}</a></td>
	        	<td><a href="${createLink(controller:'tc', action:'create', params : [tb_id : tbInstance.id])}" target="_blank">${fieldValue(bean: tbInstance, field: "tb008")}</a></td>
	        	<td><a href="${createLink(controller:'tc', action:'create', params : [tb_id : tbInstance.id])}" target="_blank">${fieldValue(bean: tbInstance, field: "tb003")}</a></td>
	        	<td><a href="${createLink(controller:'tc', action:'create', params : [tb_id : tbInstance.id])}" target="_blank">${fieldValue(bean: tbInstance, field: "tb011")}</a></td>
	        	<td><a href="${createLink(controller:'tc', action:'create', params : [tb_id : tbInstance.id])}" target="_blank">${fieldValue(bean: tbInstance, field: "tb012")}</a></td>
	        	<td><a href="${createLink(controller:'tc', action:'create', params : [tb_id : tbInstance.id])}" target="_blank">${fieldValue(bean: tbInstance, field: "tb004")}</a></td>
	        	<td><a href="${createLink(controller:'tc', action:'create', params : [tb_id : tbInstance.id])}" target="_blank">${fieldValue(bean: tbInstance, field: "tb005")}</a></td>
	        	<td><a href="${createLink(controller:'tc', action:'create', params : [tb_id : tbInstance.id])}" target="_blank">${fieldValue(bean: tbInstance, field: "tb006")}</a></td>
	            <td><a href="${createLink(controller:'tc', action:'create', params : [tb_id : tbInstance.id])}" target="_blank">${tbInstance.tcs*.tc002.sum()}</a></td>
	            <td><a href="${createLink(controller:'tc', action:'create', params : [tb_id : tbInstance.id])}" target="_blank"><g:formatDate format="yyyy-MM-dd" date="${tbInstance.beginDate}" /></a></td>
	            <td><a href="${createLink(controller:'tc', action:'create', params : [tb_id : tbInstance.id])}" target="_blank"><g:formatDate format="yyyy-MM-dd" date="${tbInstance.endDate}" /></a></td>
	            <td><a href="${createLink(controller:'tc', action:'create', params : [tb_id : tbInstance.id])}" target="_blank">${formatNumber(number : tbInstance.tb009, format: '###,##0.000000')}</a></td>
	        </tr>
	    </g:each>
	    </tbody>
	</table>
</div>
<div class="paginateButtons">
    <g:paginate action="show" max="100" total="${tbInstanceTotal}" params="[id: ta_id, line : params.line]" />
</div>